GINO Graphics Suite - GINO v9.0  

Point Storage

With the drawing of arcs and curves, GINO generates many internal points in addition to those directly specified by the calling routine. There are cases where an application needs to know the location of these points in order to define a polygon boundary or carry out other graphical or mathematical manipulation on them.

GINO provides facilities for both these options by storing all the points between which vectors are drawn (whether it be for straight lines or the small vectors that make up arcs and curves) in an internal storage buffer. Depending on the desired use of the internal points, up to two separate buffer areas can be defined, one for polygon definition and one for simple point storage. In both cases the buffers are contained in the global GINO workspace area which should be defined at the start of an application through the routine gSetWorkspaceLimit() (see Workspaces).

Once the global workspace has been defined, the two possible storage areas are defined using one or both of the following routines:

gDefinePolygonWorkspace(nw)
gDefinePointWorkspace(nw)

where nw is the number of real words required for the appropriate buffer.

The routine gDefinePolygonWorkspace() is used to define polygon workspace and the subsequent storage of points for the definition of polygons is fully described later in this document (see Advanced Polygons).

The routine gDefinePointWorkspace() defines a buffer for the simple storage of points that can be returned to the application. Each point occupies 4 words of storage, so allocating a workspace of 120 words will allow for the storage of 30 points. Note that the actual number of points generated by an arc or curve will depend on tolerance or tension of the particular arc or curve.

Point storage is started, restarted or paused using the routine:

gSetPointMode(switch)

and enquired using:

gEnqPointMode(switch)

where switch can be GOFF, GSPACE, GPICTURE or GRESTART. When the point storage mode is set to GSPACE or GPICTURE, points are stored as either untransformed (i.e. as supplied by the user) or transformed (i.e. as they appear on the drawing area with respect to the current viewport) coordinates respectively. Storage is switched off using the GOFF setting and restarted (in the current mode) when GSPACE or GPICTURE is used again.

If the point storage mode is changed from GSPACE to GPICTURE or vice-versa or GCLEAR is used in gSetPointMode(), all previously stored points are thrown away.

The stored points are returned to the user through the function:

[F90/C++]

nret=gReturnInternalPoints2D(nn, points2, np, polylines2, npts, npol)

[VB.NET]

nret=gReturnInternalPoints2D(lverts, np, xarr, yarr, nn, npts, npol)

where points2 is an array of type GPOINT and polylines2 is an array of type GPOLYGON. (or in the case of vb.net, all points are returned in the arrays xarr,yarr and the number in each polygon is returned in the array lverts).  The arguments nn and np should be set to the size of these arrays. The arguments npts and npol return the number of points and polylines that actually exist in the internal workspace which may be more than those returned if the supplied arrays are not sufficiently large enough. The function itself returns the actual number of complete polylines that have been placed in the user supplied arrays.

In order to enquire how much data has been stored, gReturnInternalPoints2D() can be called with nn and np set to 1, in which case the total space for all the points and polylines can be allocated using the values of npts and npol. The function can then be called a second time to return all the stored data.

The routine returns the stored points both as a set of vertices in the points2 array and a set of polylines in the polylines2 array. This in fact represents the same data but in two different formats with the latter being a more accurate definition of the information stored. Note that the GPOLYGON structure contains pointers into the GPOINT array and that any 3rd dimension (Z coordinate) is ignored in the call to gReturnInternalPoints2D().

The following example shows a usage of the gReturnInternalPoints2D() routine:

[C/C++]
#include <gino-c.h>
#define NN 300
#define NP 4
GPOINT pts[NN];
GPOLYGON pol[NP];
#if defined(MWIN) || defined(WOGL)
int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
%%%%%% LPSTR lpszCmdParam, int nCmdShow)
#else
int main ()
#endif
{
   int nret,npts,npol;
      gOpenGino();
      gMwin(hInstance,hPrevInstance);
/* Define global and point workspace */
      gSetWorkspaceLimit(2000);
      gDefinePointWorkspace(1000);
/* Set point storage mode */
      gSetPointMode(GSPACE);
/* Draw some graphics */
      gMoveTo2D(10.0,10.0);
      gDrawLineBy2D(5.0,5.0);
      gDrawLineBy2D(-5.0,5.0);
      gDrawArcBy2D(0.0,-5.0,0.0,-10.0,GANTICLOCKWISE);
      gMoveTo2D(0.0,10.0);
      gMoveTo2D(30.0,10.0);
      gDrawLineBy2D(5.0,5.0);
      gDrawLineBy2D(-5.0,5.0);
      gDrawArcBy2D(0.0,-5.0,0.0,-10.0,GANTICLOCKWISE);
      gMoveTo2D(40.0,10.0);
      gMoveTo2D(50.0,10.0);
      gDrawLineBy2D(5.0,5.0);
      gDrawLineBy2D(-5.0,5.0);
      gDrawArcBy2D(0.0,-5.0,0.0,-10.0,GANTICLOCKWISE);
/* Switch point storage off */
      gSetPointMode(GOFF);
/* Return internal storage */
      nret=gReturnInternalPoints2D(NN,pts,NP,pol,&npts,&npol);
/* Fill polygon set */
      gFillPolygonSet2D(6,1,GAREA,nret,pol);
      gSuspendDevice();
      gCloseGino();
}
[F90]
use gino_f90
parameter (nn=300, np=4)
type (GPOINT) :: pts(nn)
type (GPOLYGON) :: pol(np)
      call gOpenGino
      call xxxxx
! Define global and point workspace
      call gSetWorkspaceLimit(1,2000)
      call gDefinePointWorkspace(1000)
! Set point storage mode
      call gSetPointMode(GSPACE)
! Draw some graphics
      call gMoveTo2D(10.0,10.0)
      call gDrawLineBy2D(5.0,5.0)
      call gDrawLineBy2D(-5.0,5.0)
      call gDrawArcBy2D(0.0,-5.0,0.0,-10.0,GANTICLOCKWISE)
      call gMoveTo2D(0.0,10.0)
      call gMoveTo2D(30.0,10.0)
      call gDrawLineBy2D(5.0,5.0)
      call gDrawLineBy2D(-5.0,5.0)
      call gDrawArcBy2D(0.0,-5.0,0.0,-10.0,GANTICLOCKWISE)
      call gMoveTo2D(40.0,10.0)
      call gMoveTo2D(50.0,10.0)
      call gDrawLineBy2D(5.0,5.0)
      call gDrawLineBy2D(-5.0,5.0)
      call gDrawArcBy2D(0.0,-5.0,0.0,-10.0,GANTICLOCKWISE)
! Switch point storage off
      call gSetPointMode(GOFF)
! Return internal storage
      nret=gReturnInternalPoints2D(nn,pts,np,pol,npts,npol)
! Fill polygon set
      call gFillPolygonSet2D(6,1,GAREA,nret,pol)
      call gSuspendDevice
      call gCloseGino
      stop
      end

Poiint Storage

The outline of each object is drawn with lines and arcs, then the points of each polygon is retrieved with gReturnInternalPoints2D() and the polygon set is filled with gFillPolygonSet2D().